-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(destination): prevent task leak in federated service watchers #14693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…lock indefinitely When unsubscribing a stream from a federated service, we: 1. For each cluster, send an update on the stream's channel to remove endpoints. 2. Call synchronizedGetStream.Stop() so that it stops processing updates. These steps can race and deadlock: if Stop() has been called before endoint updates are processed, the subsequent Send() calls block forever. This change improves test coverage to cover this case as well as that fixed in f4e6795.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds robust error handling to synchronizedGetStream.Send() to prevent goroutine leaks when the stream is stopped, along with comprehensive test coverage for the new behavior.
- Modified
Send()method to returnerrStreamStoppederror when called afterStop(), preventing indefinite blocking - Added two test cases verifying that
Send()returns promptly afterStop()is called, even when the inner stream is blocked
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| controller/api/destination/syncronized_get_stream.go | Updated Send() method with graceful shutdown logic using select statements to check if stream is stopped before and during channel send operations |
| controller/api/destination/syncronized_get_stream_test.go | Added comprehensive test coverage with two test functions and a blocking mock server to verify Send behavior after Stop is called |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
zaharidichev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Solid test coverage
adleong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
When unsubscribing a stream from a federated service, we:
These steps can race and deadlock and task leak: if Stop() has been called before endoint updates are processed, the subsequent Send() calls block forever.
This change improves test coverage to cover this case as well as that fixed in f4e6795.